//
//  ImageCategoryTableViewCell.swift
//  PhotoTestDemo
//
//  Created by 惠 on 2020/9/9.
//  Copyright © 2020 惠. All rights reserved.
//

import UIKit

class ImageCategoryTableViewCell: UITableViewCell {
    
    var colorType: ColorType! {
        didSet {
            switch colorType {
            case .defaults:
                selectItemImage.image = UIImage(named: "selectCategory", in: Resources.getBundle, compatibleWith: nil)
            case .red:
                selectItemImage.image = UIImage(named: "redSelectCategory", in: Resources.getBundle, compatibleWith: nil)
            case .none:
                selectItemImage.image = UIImage(named: "selectCategory", in: Resources.getBundle, compatibleWith: nil)
            }
        }
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setUI()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
//MARK: -懒加载UI
    lazy var contentImage: UIImageView = {
        let contentImage = UIImageView(frame: CGRect(origin: CGPoint(x: 15, y: 10), size: CGSize(width: 50, height: 50)))
        return contentImage
    }()
    
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel(frame: CGRect(origin: CGPoint(x: 75, y: 17), size: CGSize(width: UIScreen.main.bounds.width-120, height: 18)))
        titleLabel.font = UIFont.init(name: "Helvetica-Bold", size: 13)
        titleLabel.textAlignment = .left
        titleLabel.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
        return titleLabel
    }()
    
    lazy var countLabel: UILabel = {
        let countLabel = UILabel(frame: CGRect(origin: CGPoint(x: 75, y: 35), size: CGSize(width: 100, height: 18)))
        countLabel.font = UIFont.systemFont(ofSize: 13)
        countLabel.textAlignment = .left
        countLabel.textColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1)
        return countLabel
    }()
    
    lazy var selectItemImage: UIImageView = {
        let selectItemImage = UIImageView(frame: CGRect(origin: CGPoint(x: UIScreen.main.bounds.width-35, y: 28), size: CGSize(width: 19, height: 13)))
//        selectItemImage.image = UIImage(named: "selectCategory", in: Resources.getBundle, compatibleWith: nil)
        selectItemImage.isHidden = true
        return selectItemImage
    }()
    
    //MARK: -设置UI
    func setUI() {
        backgroundColor = .white
        
        addSubview(contentImage)
        addSubview(titleLabel)
        addSubview(countLabel)
        addSubview(selectItemImage)
    }
}
